package com.lianbang.pharmacy.adapter

import android.text.SpannableString
import android.text.style.LeadingMarginSpan
import cn.ubest.mvvmcore.utils.ResourcesUtils
import cn.ubest.mvvmcore.utils.SpanUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.lianbang.pharmacy.R
import com.lianbang.pharmacy.bean.CouponListBean


/**
 * Created by maoqi on 2020/12/15.
 */
class MyCouponListAdapter :
    BaseQuickAdapter<CouponListBean, BaseViewHolder>(R.layout.item_my_coupon_list), LoadMoreModule {
    override fun convert(helper: BaseViewHolder, item: CouponListBean) {
        val spannableString = SpannableString(item.coupon_title)
        spannableString.setSpan(
            LeadingMarginSpan.Standard(ResourcesUtils.getDimens(R.dimen.dp_30), 0),
            0,
            spannableString.length,
            SpannableString.SPAN_INCLUSIVE_INCLUSIVE
        )
        helper.setBackgroundColor(R.id.iv_img, ResourcesUtils.getColor(R.color.black))
            .setText(R.id.tv_title, spannableString)
            .setText(
                R.id.tv_new_price, SpanUtils()
                    .append("领劵后¥")
                    .setFontSize(ResourcesUtils.getDimens(R.dimen.dp_8))
                    .append(item.coupon_price).setBold()
                    .create()
            )
            .setText(
                R.id.tv_coupon_price,
                SpanUtils().append("¥").append("200").setFontSize(28, true).create()
            )
            .setText(R.id.tv_coupon_category, "无门槛券")
            .setText(R.id.tv_date, "2020.11.19-2020.12.01")
    }

}